<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->

<link href="<%=basePath %>resources/css/bootstrap.min.css" rel="stylesheet" media="screen">
<script src="<%=basePath %>resources/jslib/jquery.js"></script>
<script src="<%=basePath %>resources/jslib/bootstrap.min.js"></script>
<script  type="text/javascript">

//登录
	function saveDeviceInfo() {
		$("#mes").show();
		$("#mes").html("&nbsp;&nbsp;正在通讯中...");
		
		
		var deviceName=$("#deviceName").val();
		if(deviceName.length<1){
			$("#mes").html("&nbsp;&nbsp;零件反馈零件信息不能为空");
			return ;
		}
		
		
		var devicedesc=$("#devicedesc").val();
		if(devicedesc.length<1){
			$("#mes").html("&nbsp;&nbsp;零件反馈内容不能为空");
			return ;
		}
		//登录处理
		var param={"lingJianId":$("#lingJianId").val(),
				  "content":$("#deviceRemark").val(),
				  "descript":$("#devicedesc").val()
				  };
		$.ajax({
			type: "post",
			contentType: "application/json;charset=utf-8",
			url : "<%=basePath %>user/addFeedBack.action",
			data :JSON.stringify(param) ,
			success : function(data){
                       if(data.code=="0000"){
                          alert("添加成功"); 
                          $("#mes").html("&nbsp;&nbsp;添加成功，请继续添加...");
                       }else{
                          $("#mes").html(data.code+"##"+data.message);
                        }
                      
             },
			 dataType : "json"
		});
	}
	
	function clearLingJian(){
		 $("#deviceName").val("");
  	   $("#xingHao").val("");
  	   $("#lingJianId").val("");
		
	}
	function findLingJian(){
		var bianhao=$("#bianHao").val();
		if(bianhao.length<1){
			
			return ;
		}
		$.ajax({
			type: "post",
			url : "<%=basePath %>lingJian/findLingJianInfo.action",
			data :{"bianHao":bianhao},
			success : function(data){
                       if(data.code=="0000"){
                    	   $("#deviceName").val(data.result.name);
                    	   $("#xingHao").val(data.result.xingHao);
                    	   $("#lingJianId").val(data.result.id);
                       }else{
                           $("#mes").html(data.code+"##"+data.message);
                        }
                      
             },
			 dataType : "json"
		});
	}
</script>
</head>
<body>
<ol class="breadcrumb">
	<li><a href="#">登陆</a></li>
	<li><a href="#">首页</a></li>
	<li class="active">零件质量反馈添加</li>
</ol>


<form class="form-horizontal" role="form">

 <input class="form-control" id="lingJianId" type="hidden" >
  <div class="form-group">
    <label class="col-sm-2 control-label">零件编号：</label>
    <div class="col-sm-10">
      <input class="form-control" id="bianHao" type="text"  onblur="findLingJian()" onfocus="clearLingJian()" placeholder="请输入零件编号查询">
    </div>
  </div>
  
  <div class="form-group">
    <label class="col-sm-2 control-label">零件名称：</label>
    <div class="col-sm-10">
      <input class="form-control" id="deviceName" type="text" readonly="readonly" placeholder="请确认零件名称">
    </div>
  </div>
  
  
   <div class="form-group">
    <label class="col-sm-2 control-label">零件型号：</label>
    <div class="col-sm-10">
      <input class="form-control" id="xingHao" type="text"  readonly="readonly" placeholder="请确认零件型号">
    </div>
  </div>
  
  <div class="form-group">
     <label class="col-sm-2 control-label">问题描述：</label>
       <div class="col-sm-10">
    <textarea class="form-control" rows="3" id="devicedesc" ></textarea>
      </div>
  </div>

 <div class="form-group">
     <label class="col-sm-2 control-label">其他留言：</label>
       <div class="col-sm-10">
    <textarea class="form-control" rows="3" id="deviceRemark" ></textarea>
      </div>
  </div>

   <div class="form-group">
       <label class="col-sm-2 control-label" for="inputSuccess"></label>
       <button type="button"  class="btn btn-success"  onclick="saveDeviceInfo()">确认保存</button>
      
    </div>
     <div class="form-group">
       <label class="col-sm-2 control-label" for="inputSuccess"></label>
       <p class="text-success" id="mes"></p>
    </div>
</form>

</body>
</html>